package cn.itcast.bos.mq;

import javax.jms.JMSException;
import javax.jms.MapMessage;
import javax.jms.Message;
import javax.jms.MessageListener;

import org.springframework.stereotype.Service;

import cn.itcast.bos.utils.SmsUtils;

@Service("smsConsumer")
public class SmsConsumer implements MessageListener{

	@Override
	public void onMessage(Message message) {
		MapMessage mapMessage=(MapMessage)message;
//		String result = SmsUtils.sendSmsByHTTP(model.getTelephone(), msg);
			String result="000/xxxx";
				try {
					if(result.startsWith("000")){
					System.out.println("发送短信成功,手机号码:"+mapMessage.getString("telephone")
					+",验证码是:"+mapMessage.getString("sms"));
					}else{
						throw new RuntimeException("短信发送失败,信息码是:"+result);
					}
				} catch (JMSException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
	}
}
